import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/widget/screenutil/custom_screenutil.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:flutter_pickers/address_picker/route/address_picker_route.dart';
import 'package:flutter_pickers/pickers.dart';
import 'package:flutter_pickers/style/picker_style.dart';
import 'package:get/get.dart';

///
/// 选择
///
class AddressPicker {

  static void show(BuildContext context, {
    String initProvince = '',
    String initCity = '',
    String? initTown,
    AddressCallback? onConfirm
  }) {
    FocusScopeNode currentFocus = FocusScope.of(context);
    if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
      FocusManager.instance.primaryFocus!.unfocus();
    }

    Pickers.showAddressPicker(
      context,
      initProvince: initProvince,
      initCity: initCity,
      initTown: initTown,
      addAllItem: false,
      onConfirm: onConfirm,
      pickerStyle: pickerStyle());

    // showModalBottomSheet(
    //   context: Get.context!,
    //   backgroundColor: Colors.transparent,
    //   builder: (context) {
    //     return Material(
    //       color: Colors.white,
    //       borderRadius: const BorderRadius.only(
    //         topLeft: Radius.circular(10),
    //         topRight: Radius.circular(10)
    //       ),
    //       child: Container(
    //         padding: const EdgeInsets.only(top: 4),
    //         child: picker.makePicker(null, true),
    //       )
    //     );
    //   }
    // );
  }


  static pickerStyle() {
    return PickerStyle(
      cancelButton: Padding(
        padding: EdgeInsets.symmetric(horizontal: 16.w),
        child: Text('取消',style: TextStyle(color: const Color(0xffcccccc), fontSize: 16.sp),),
      ),
      commitButton: Padding(
        padding: EdgeInsets.symmetric(horizontal: 16.w), 
        child: Text('确定', style: TextStyle(color: const Color(0xff499360), fontSize: 16.sp),)
      ),
      textSize: 14.sp,
    );
  }

}